home *** CD-ROM | disk | FTP | other *** search
/ Internet News 1999 February / InternetNews_1999_02.iso / pc / Articoli / dynamicHtml / Esempi9807 / Esempio 3 / menus.js < prev    next >
Text File  |  1998-01-25  |  23KB  |  683 lines

  1.     /*  The following statement must not be removed from this code:
  2.         This code is copyright 1997, 1998 insideDHTML.com, LLC. All rights rserved.
  3.     HTTP://www.insideDHTML.com
  4.  
  5.     This code was modified from the original menu toolkit code by Pete Lyons with the
  6.     permission of Scott Isaacs.
  7.     */
  8.  
  9.     var childActive = null 
  10.     var menuActive = null
  11.     var lastHighlight = null
  12.     var active = false
  13.  
  14.     function getReal(el) {
  15.       // Find a table cell element in the parent chain */
  16.       temp = el
  17.       if (temp.tagName=="TD")
  18.         el = temp
  19.       while ((temp.tagName!="TABLE") && (temp.className!="root") && (temp.id!="menuBar")) {
  20.         temp = temp.offsetParent
  21.         if (temp.tagName=="TD")
  22.           el = temp
  23.       }
  24.       return el
  25.     }
  26.     function getReal2(el) {
  27.       // Find a table cell element in the parent chain */
  28.       temp = el
  29.       if (temp.tagName=="TD")
  30.         el = temp
  31.       while ((temp.tagName!="TABLE") && (temp.className!="root") && (temp.id!="menuBar2")) {
  32.         temp = temp.offsetParent
  33.         if (temp.tagName=="TD")
  34.           el = temp
  35.       }
  36.       return el
  37.     }
  38.     function getReal3(el) {
  39.       // Find a table cell element in the parent chain */
  40.       temp = el
  41.       if (temp.tagName=="TD")
  42.         el = temp
  43.       while ((temp.tagName!="TABLE") && (temp.className!="root") && (temp.id!="menuBar3")) {
  44.         temp = temp.offsetParent
  45.         if (temp.tagName=="TD")
  46.           el = temp
  47.       }
  48.       return el
  49.     }
  50.  
  51.     function raiseMenu(el) {
  52.       el.style.borderLeft = "0px #EEEEEE solid"
  53.       el.style.borderTop = "0px #EEEEEE solid"
  54.       el.style.borderRight = "0px gray solid"
  55.       el.style.borderBottom = "0px gray solid"
  56.     }
  57.     function clearHighlight(el) {
  58.       if (el==null) return
  59.       el.style.borderRight = "0px lightgrey solid"
  60.       el.style.borderBottom = "0px lightgrey solid"
  61.       el.style.borderTop = "0px lightgrey solid"
  62.       el.style.borderLeft = "0px lightgrey solid" 
  63.     }
  64.  
  65.     function sinkMenu(el) {
  66.       el.style.borderRight = "0px #EEEEEE solid"
  67.       el.style.borderBottom = "0px #EEEEEE solid"
  68.       el.style.borderTop = "0px gray solid"
  69.       el.style.borderLeft = "0px gray solid"
  70.     }
  71.     function menuHandler(menuItem) {
  72.       // Write generic menu handlers here!
  73.       // Returning true collapses the menu. Returning false does not collapse the menu
  74.       return true
  75.     }
  76.     function processClick() {
  77.       var el = getReal(event.srcElement)
  78.       if ((el.offsetParent.offsetParent.id=="menuBar") && (active)) {        
  79.         cleanupMenu(menuActive)
  80.         clearHighlight(menuActive)
  81.         active=false
  82.         lastHighlight=null
  83.         doHighlight(el)
  84.       }
  85.       else {
  86.         if ((el.className=="root") || (!menuHandler(el))) 
  87.           doMenuDown(el)
  88.         else {
  89.           if (el._childItem==null) 
  90.             el._childItem = getChildren(el)
  91.           if (el._childItem!=null)  return;
  92.           if ((el.id!="break") && (el.className!="disabled") && (el.className!="disabledhighlight") && (el.className!="clear"))  {
  93.             if (menuHandler(el)) {
  94.               cleanupMenu(menuActive)
  95.               clearHighlight(menuActive)
  96.               active=false
  97.               lastHighlight=null
  98.             }
  99.           }
  100.         }
  101.       }
  102.     }
  103.     function processClick2() {
  104.       var el = getReal2(event.srcElement)
  105.       if ((el.offsetParent.offsetParent.id=="menuBar2") && (active)) {        
  106.         cleanupMenu(menuActive)
  107.         clearHighlight(menuActive)
  108.         active=false
  109.         lastHighlight=null
  110.         doHighlight(el)
  111.       }
  112.       else {
  113.         if ((el.className=="root") || (!menuHandler(el))) 
  114.           doMenuDown(el)
  115.         else {
  116.           if (el._childItem==null) 
  117.             el._childItem = getChildren(el)
  118.           if (el._childItem!=null)  return;
  119.           if ((el.id!="break") && (el.className!="disabled") && (el.className!="disabledhighlight") && (el.className!="clear"))  {
  120.             if (menuHandler(el)) {
  121.               cleanupMenu(menuActive)
  122.               clearHighlight(menuActive)
  123.               active=false
  124.               lastHighlight=null
  125.             }
  126.           }
  127.         }
  128.       }
  129.     }
  130.     function processClick3() {
  131.       var el = getReal3(event.srcElement)
  132.       if ((el.offsetParent.offsetParent.id=="menuBar3") && (active)) {        
  133.         cleanupMenu(menuActive)
  134.         clearHighlight(menuActive)
  135.         active=false
  136.         lastHighlight=null
  137.         doHighlight(el)
  138.       }
  139.       else {
  140.         if ((el.className=="root") || (!menuHandler(el))) 
  141.           doMenuDown(el)
  142.         else {
  143.           if (el._childItem==null) 
  144.             el._childItem = getChildren(el)
  145.           if (el._childItem!=null)  return;
  146.           if ((el.id!="break") && (el.className!="disabled") && (el.className!="disabledhighlight") && (el.className!="clear"))  {
  147.             if (menuHandler(el)) {
  148.               cleanupMenu(menuActive)
  149.               clearHighlight(menuActive)
  150.               active=false
  151.               lastHighlight=null
  152.             }
  153.           }
  154.         }
  155.       }
  156.     }
  157.  
  158.     function getChildren(el) {
  159.       var tList = el.children.tags("TABLE")
  160.       var i = 0
  161.       while ((i<tList.length) && (tList[i].tagName!="TABLE"))
  162.         i++
  163.       if (i==tList.length)
  164.         return null
  165.       else
  166.         return tList[i]
  167.     }
  168.     function doMenuDown(el) {
  169.       if (el._childItem==null) 
  170.         el._childItem = getChildren(el)
  171.       if ((el._childItem!=null) && (el.className!="disabled") && (el.className!="disabledhighlight")) {
  172.         // Performance Optimization - Cache child element
  173.         ch = el._childItem
  174.         if (ch.style.display=="block") {
  175.           removeHighlight(ch.active)
  176.           return
  177.         }
  178.         ch.style.display = "block"
  179.         if (el.className=="root") {
  180.           ch.style.pixelTop = el.offsetParent.offsetTop
  181.           ch.style.pixelLeft = el.offsetParent.offsetWidth
  182.           sinkMenu(el)
  183.           active = true
  184.           menuActive = el
  185.         } else {
  186.           childActive = el
  187.           ch.style.pixelLeft = el.offsetParent.offsetWidth
  188.           ch.style.pixelTop = el.offsetParent.offsetTop
  189.         }     
  190.       }
  191.     }
  192.     function doHighlight(el) {
  193.       el = getReal(el)
  194.       if ("root"==el.className) {
  195.         if ((menuActive!=null) && (menuActive!=el)) {
  196.           clearHighlight(menuActive)
  197.         }
  198.         if (!active) {
  199.           raiseMenu(el)
  200.         }          
  201.         else {
  202.           sinkMenu(el)}
  203.         if ((active) && (menuActive!=el)) {
  204.           cleanupMenu(menuActive)          
  205.           doMenuDown(el)
  206.         }
  207.         menuActive = el  
  208.         lastHighlight=null
  209.       }
  210.       else {
  211.         if (childActive!=null) 
  212.           if (!childActive.contains(el)) 
  213.             closeMenu(childActive, el)    
  214.         if (("TD"==el.tagName) && ("clear"!=el.className)) {
  215.           var ch = el.offsetParent.offsetParent          
  216.           if (ch.active!=null) {
  217.             if (ch.active!=el) {
  218.               if (ch.active.className=="disabledhighlight")  
  219.                 ch.active.className="disabled"
  220.               else
  221.                 ch.active.className=""
  222.               }
  223.             }
  224.           ch.active = el
  225.           lastHighlight = el
  226.           if ((el.className=="disabled") || (el.className=="disabledhighlight") || (el.id=="break")) 
  227.             el.className = "disabledhighlight"
  228.           else {
  229.             if (el.id!="break") {
  230.               el.className = "highlight"
  231.               if (el._childItem==null) 
  232.                 el._childItem = getChildren(el)
  233.               if (el._childItem!=null) {
  234.                 doMenuDown(el)
  235.               }
  236.             }  
  237.           }
  238.         }
  239.       }
  240.     }
  241.     function doHighlight2(el) {
  242.       el = getReal2(el)
  243.       if ("root"==el.className) {
  244.         if ((menuActive!=null) && (menuActive!=el)) {
  245.           clearHighlight(menuActive)
  246.         }
  247.         if (!active) {
  248.           raiseMenu(el)
  249.         }          
  250.         else {
  251.           sinkMenu(el)}
  252.         if ((active) && (menuActive!=el)) {
  253.           cleanupMenu(menuActive)          
  254.           doMenuDown(el)
  255.         }
  256.         menuActive = el  
  257.         lastHighlight=null
  258.       }
  259.       else {
  260.         if (childActive!=null) 
  261.           if (!childActive.contains(el)) 
  262.             closeMenu(childActive, el)    
  263.         if (("TD"==el.tagName) && ("clear"!=el.className)) {
  264.           var ch = el.offsetParent.offsetParent          
  265.           if (ch.active!=null) {
  266.             if (ch.active!=el) {
  267.               if (ch.active.className=="disabledhighlight")  
  268.                 ch.active.className="disabled"
  269.               else
  270.                 ch.active.className=""
  271.               }
  272.             }
  273.           ch.active = el
  274.           lastHighlight = el
  275.           if ((el.className=="disabled") || (el.className=="disabledhighlight") || (el.id=="break")) 
  276.             el.className = "disabledhighlight"
  277.           else {
  278.             if (el.id!="break") {
  279.               el.className = "highlight"
  280.               if (el._childItem==null) 
  281.                 el._childItem = getChildren(el)
  282.               if (el._childItem!=null) {
  283.                 doMenuDown(el)
  284.               }
  285.             }  
  286.           }
  287.         }
  288.       }
  289.     }
  290.     function doHighlight3(el) {
  291.       el = getReal3(el)
  292.       if ("root"==el.className) {
  293.         if ((menuActive!=null) && (menuActive!=el)) {
  294.           clearHighlight(menuActive)
  295.         }
  296.         if (!active) {
  297.           raiseMenu(el)
  298.         }          
  299.         else {
  300.           sinkMenu(el)}
  301.         if ((active) && (menuActive!=el)) {
  302.           cleanupMenu(menuActive)          
  303.           doMenuDown(el)
  304.         }
  305.         menuActive = el  
  306.         lastHighlight=null
  307.       }
  308.       else {
  309.         if (childActive!=null) 
  310.           if (!childActive.contains(el)) 
  311.             closeMenu(childActive, el)    
  312.         if (("TD"==el.tagName) && ("clear"!=el.className)) {
  313.           var ch = el.offsetParent.offsetParent          
  314.           if (ch.active!=null) {
  315.             if (ch.active!=el) {
  316.               if (ch.active.className=="disabledhighlight")  
  317.                 ch.active.className="disabled"
  318.               else
  319.                 ch.active.className=""
  320.               }
  321.             }
  322.           ch.active = el
  323.           lastHighlight = el
  324.           if ((el.className=="disabled") || (el.className=="disabledhighlight") || (el.id=="break")) 
  325.             el.className = "disabledhighlight"
  326.           else {
  327.             if (el.id!="break") {
  328.               el.className = "highlight"
  329.               if (el._childItem==null) 
  330.                 el._childItem = getChildren(el)
  331.               if (el._childItem!=null) {
  332.                 doMenuDown(el)
  333.               }
  334.             }  
  335.           }
  336.         }
  337.       }
  338.     }
  339.  
  340.     function removeHighlight(el) {
  341.       if (el!=null)
  342.         if ((el.className=="disabled") || (el.className=="disabledhighlight"))  
  343.           el.className="disabled"
  344.         else
  345.           el.className=""
  346.     }
  347.     function cleanupMenu(el) {
  348.       if (el==null) return
  349.       for (var i = 0; i < el.all.length; i++) {
  350.         var item = el.all[i]
  351.         if (item.tagName=="TABLE")
  352.          item.style.display = ""
  353.         removeHighlight(item.active)
  354.         item.active=null
  355.       }
  356.     }
  357.     function closeMenu(ch, el) {
  358.       var start = ch
  359.       while (ch.className!="root") {
  360.           ch = ch.parentElement
  361.           if (((!ch.contains(el)) && (ch.className!="root"))) {
  362.             start=ch
  363.           }
  364.       }
  365.       cleanupMenu(start)
  366.     }
  367.     function checkMenu() {      
  368.       if (document.all.menuBar==null) {
  369.         clearHighlight(menuActive)
  370.         closeMenu(menuActive)
  371.         active = false
  372.         menuActive=null
  373.         choiceActive = null
  374.       }
  375.       if (document.all.menuBar2==null) {
  376.         clearHighlight(menuActive)
  377.         closeMenu(menuActive)
  378.         active = false
  379.         menuActive=null
  380.         choiceActive = null
  381.       }
  382.       if (document.all.menuBar3==null) {
  383.         clearHighlight(menuActive)
  384.         closeMenu(menuActive)
  385.         active = false
  386.         menuActive=null
  387.         choiceActive = null
  388.       }
  389.     }
  390.  
  391.     function doCheckOut() {
  392.       var el = event.toElement      
  393.       if ((!active) && (menuActive!=null) && (!menuActive.contains(el))) {
  394.         clearHighlight(menuActive)
  395.         menuActive=null
  396.       }
  397.     }
  398.     function doCheckOut2() {
  399.       var el = event.toElement      
  400.       if ((!active) && (menuActive!=null) && (!menuActive.contains(el))) {
  401.         clearHighlight(menuActive)
  402.         menuActive=null
  403.       }
  404.     }
  405.     function doCheckOut3() {
  406.       var el = event.toElement      
  407.       if ((!active) && (menuActive!=null) && (!menuActive.contains(el))) {
  408.         clearHighlight(menuActive)
  409.         menuActive=null
  410.       }
  411.     }
  412.  
  413.     function processKey() {
  414.       if (active) {
  415.         switch (event.keyCode) {
  416.          case 13: lastHighlight.click(); break;
  417.          case 39:  // right
  418.            if ((lastHighlight==null) || (lastHighlight._childItem==null)) {
  419.              var idx = menuActive.cellIndex
  420.              if (idx==menuActive.offsetParent.cells.length-2)
  421.                idx = 0
  422.              else
  423.                idx++
  424.              newItem = menuActive.offsetParent.cells[idx]
  425.            } else
  426.            {
  427.              newItem = lastHighlight._childItem.rows[0].cells[0]
  428.            }
  429.            doHighlight(newItem)
  430.            break; 
  431.          case 37: //left
  432.            if ((lastHighlight==null) || (lastHighlight.offsetParent.offsetParent.offsetParent.id=="menuBar")) {
  433.              var idx = menuActive.cellIndex
  434.              if (idx==0)
  435.                idx = menuActive.offsetParent.cells.length-2
  436.              else
  437.                idx--
  438.              newItem = menuActive.offsetParent.cells[idx]
  439.            } else
  440.            {
  441.              newItem = lastHighlight.offsetParent
  442.              while (newItem.tagName!="TD")
  443.                newItem = newItem.parentElement
  444.            }
  445.            doHighlight(newItem)
  446.            break; 
  447.          case 40: // down
  448.             if (lastHighlight==null) {
  449.               itemCell = menuActive._childItem
  450.               curCell=0
  451.               curRow = 0
  452.             }
  453.             else {
  454.               itemCell = lastHighlight.offsetParent.offsetParent
  455.               if (lastHighlight.cellIndex==lastHighlight.offsetParent.cells.length-1) {
  456.                 curCell = 0
  457.                 curRow = lastHighlight.offsetParent.rowIndex+1
  458.                 if (lastHighlight.offsetParent.rowIndex==itemCell.rows.length-1)
  459.                   curRow = 0
  460.               } else {
  461.                 curCell = lastHighlight.cellIndex+1
  462.                 curRow = lastHighlight.offsetParent.rowIndex
  463.               }
  464.             }
  465.             doHighlight(itemCell.rows[curRow].cells[curCell])
  466.             break;
  467.          case 38: // up
  468.             if (lastHighlight==null) {
  469.               itemCell = menuActive._childItem
  470.               curRow = itemCell.rows.length-1
  471.               curCell= itemCell.rows[curRow].cells.length-1
  472.             }
  473.             else {
  474.               itemCell = lastHighlight.offsetParent.offsetParent
  475.               if (lastHighlight.cellIndex==0) {
  476.                 curRow = lastHighlight.offsetParent.rowIndex-1
  477.                 if (curRow==-1)
  478.                   curRow = itemCell.rows.length-1
  479.                 curCell= itemCell.rows[curRow].cells.length-1
  480.  
  481.               } else {
  482.                 curCell = lastHighlight.cellIndex - 1
  483.                 curRow = lastHighlight.offsetParent.rowIndex
  484.               }
  485.             }
  486.             doHighlight(itemCell.rows[curRow].cells[curCell])
  487.             break;
  488.            if (lastHighlight==null) {
  489.               curCell = menuActive._childItem
  490.               curRow = curCell.rows.length-1
  491.             }
  492.             else {
  493.               curCell = lastHighlight.offsetParent.offsetParent
  494.               if (lastHighlight.offsetParent.rowIndex==0)
  495.                 curRow = curCell.rows.length-1
  496.               else
  497.                 curRow = lastHighlight.offsetParent.rowIndex-1
  498.             }
  499.             doHighlight(curCell.rows[curRow].cells[0])
  500.             break;
  501.         }
  502.       }
  503.     }
  504.     function processKey2() {
  505.       if (active) {
  506.         switch (event.keyCode) {
  507.          case 13: lastHighlight.click(); break;
  508.          case 39:  // right
  509.            if ((lastHighlight==null) || (lastHighlight._childItem==null)) {
  510.              var idx = menuActive.cellIndex
  511.              if (idx==menuActive.offsetParent.cells.length-2)
  512.                idx = 0
  513.              else
  514.                idx++
  515.              newItem = menuActive.offsetParent.cells[idx]
  516.            } else
  517.            {
  518.              newItem = lastHighlight._childItem.rows[0].cells[0]
  519.            }
  520.            doHighlight(newItem)
  521.            break; 
  522.          case 37: //left
  523.            if ((lastHighlight==null) || (lastHighlight.offsetParent.offsetParent.offsetParent.id=="menuBar2")) {
  524.              var idx = menuActive.cellIndex
  525.              if (idx==0)
  526.                idx = menuActive.offsetParent.cells.length-2
  527.              else
  528.                idx--
  529.              newItem = menuActive.offsetParent.cells[idx]
  530.            } else
  531.            {
  532.              newItem = lastHighlight.offsetParent
  533.              while (newItem.tagName!="TD")
  534.                newItem = newItem.parentElement
  535.            }
  536.            doHighlight(newItem)
  537.            break; 
  538.          case 40: // down
  539.             if (lastHighlight==null) {
  540.               itemCell = menuActive._childItem
  541.               curCell=0
  542.               curRow = 0
  543.             }
  544.             else {
  545.               itemCell = lastHighlight.offsetParent.offsetParent
  546.               if (lastHighlight.cellIndex==lastHighlight.offsetParent.cells.length-1) {
  547.                 curCell = 0
  548.                 curRow = lastHighlight.offsetParent.rowIndex+1
  549.                 if (lastHighlight.offsetParent.rowIndex==itemCell.rows.length-1)
  550.                   curRow = 0
  551.               } else {
  552.                 curCell = lastHighlight.cellIndex+1
  553.                 curRow = lastHighlight.offsetParent.rowIndex
  554.               }
  555.             }
  556.             doHighlight(itemCell.rows[curRow].cells[curCell])
  557.             break;
  558.          case 38: // up
  559.             if (lastHighlight==null) {
  560.               itemCell = menuActive._childItem
  561.               curRow = itemCell.rows.length-1
  562.               curCell= itemCell.rows[curRow].cells.length-1
  563.             }
  564.             else {
  565.               itemCell = lastHighlight.offsetParent.offsetParent
  566.               if (lastHighlight.cellIndex==0) {
  567.                 curRow = lastHighlight.offsetParent.rowIndex-1
  568.                 if (curRow==-1)
  569.                   curRow = itemCell.rows.length-1
  570.                 curCell= itemCell.rows[curRow].cells.length-1
  571.               } else {
  572.                 curCell = lastHighlight.cellIndex - 1
  573.                 curRow = lastHighlight.offsetParent.rowIndex
  574.               }
  575.             }
  576.             doHighlight(itemCell.rows[curRow].cells[curCell])
  577.             break;
  578.            if (lastHighlight==null) {
  579.               curCell = menuActive._childItem
  580.               curRow = curCell.rows.length-1
  581.             }
  582.             else {
  583.               curCell = lastHighlight.offsetParent.offsetParent
  584.               if (lastHighlight.offsetParent.rowIndex==0)
  585.                 curRow = curCell.rows.length-1
  586.               else
  587.                 curRow = lastHighlight.offsetParent.rowIndex-1
  588.             }
  589.             doHighlight(curCell.rows[curRow].cells[0])
  590.             break;
  591.         }
  592.       }
  593.     }
  594.     function processKey3() {
  595.       if (active) {
  596.         switch (event.keyCode) {
  597.          case 13: lastHighlight.click(); break;
  598.          case 39:  // right
  599.            if ((lastHighlight==null) || (lastHighlight._childItem==null)) {
  600.              var idx = menuActive.cellIndex
  601.              if (idx==menuActive.offsetParent.cells.length-2)
  602.                idx = 0
  603.              else
  604.                idx++
  605.              newItem = menuActive.offsetParent.cells[idx]
  606.            } else
  607.            {
  608.              newItem = lastHighlight._childItem.rows[0].cells[0]
  609.            }
  610.            doHighlight(newItem)
  611.            break; 
  612.          case 37: //left
  613.            if ((lastHighlight==null) || (lastHighlight.offsetParent.offsetParent.offsetParent.id=="menuBar3")) {
  614.              var idx = menuActive.cellIndex
  615.              if (idx==0)
  616.                idx = menuActive.offsetParent.cells.length-2
  617.              else
  618.                idx--
  619.              newItem = menuActive.offsetParent.cells[idx]
  620.            } else
  621.            {
  622.              newItem = lastHighlight.offsetParent
  623.              while (newItem.tagName!="TD")
  624.                newItem = newItem.parentElement
  625.            }
  626.            doHighlight(newItem)
  627.            break; 
  628.          case 40: // down
  629.             if (lastHighlight==null) {
  630.               itemCell = menuActive._childItem
  631.               curCell=0
  632.               curRow = 0
  633.             }
  634.             else {
  635.               itemCell = lastHighlight.offsetParent.offsetParent
  636.               if (lastHighlight.cellIndex==lastHighlight.offsetParent.cells.length-1) {
  637.                 curCell = 0
  638.                 curRow = lastHighlight.offsetParent.rowIndex+1
  639.                 if (lastHighlight.offsetParent.rowIndex==itemCell.rows.length-1)
  640.                   curRow = 0
  641.               } else {
  642.                 curCell = lastHighlight.cellIndex+1
  643.                 curRow = lastHighlight.offsetParent.rowIndex
  644.               }
  645.             }
  646.             doHighlight(itemCell.rows[curRow].cells[curCell])
  647.             break;
  648.          case 38: // up
  649.             if (lastHighlight==null) {
  650.               itemCell = menuActive._childItem
  651.               curRow = itemCell.rows.length-1
  652.               curCell= itemCell.rows[curRow].cells.length-1
  653.             }
  654.             else {
  655.               itemCell = lastHighlight.offsetParent.offsetParent
  656.               if (lastHighlight.cellIndex==0) {
  657.                 curRow = lastHighlight.offsetParent.rowIndex-1
  658.                 if (curRow==-1)
  659.                   curRow = itemCell.rows.length-1
  660.                 curCell= itemCell.rows[curRow].cells.length-1
  661.               } else {
  662.                 curCell = lastHighlight.cellIndex - 1
  663.                 curRow = lastHighlight.offsetParent.rowIndex
  664.               }
  665.             }
  666.             doHighlight(itemCell.rows[curRow].cells[curCell])
  667.             break;
  668.            if (lastHighlight==null) {
  669.               curCell = menuActive._childItem
  670.               curRow = curCell.rows.length-1
  671.             }
  672.             else {
  673.               curCell = lastHighlight.offsetParent.offsetParent
  674.               if (lastHighlight.offsetParent.rowIndex==0)
  675.                 curRow = curCell.rows.length-1
  676.               else
  677.                 curRow = lastHighlight.offsetParent.rowIndex-1
  678.             }
  679.             doHighlight(curCell.rows[curRow].cells[0])
  680.             break;
  681.         }
  682.       }
  683.     }